# Maintainer: Balló György <ballogyor+arch at gmail dot com>

pkgname=ciano
pkgver=0.2.4
pkgrel=5
pkgdesc='Multimedia file converter focused on simplicity'
arch=('loong64' 'x86_64')
url='https://robertsanseries.github.io/ciano/'
license=('GPL3')
depends=('ffmpeg' 'granite' 'imagemagick')
makedepends=('meson' 'vala')
source=("https://github.com/robertsanseries/$pkgname/archive/$pkgver/$pkgname-$pkgver.tar.gz"
        '0001-Handle-GIF-with-ImageMagick.patch'
        '0001-Create-output-directory-if-not-exist.patch'
        '0001-Use-standard-icon-names.patch'
        '0001-Add-support-for-conversion-and-selection-of-OPUS-aud.patch'
        '0001-Add-support-for-conversion-and-selection-of-WEBP-ima.patch')
sha256sums=('cdb7f77f10e4b7a64520d618472de97955ce897d26468055666291672db58754'
            '8b44b7df58f82d0ff38572b773724b6f42e085fc1a1aa098776c794eb117b49d'
            'f682329bc9cbed2d0605b31e1cc4915c9a7e188bb398fed88001e892f44c50bb'
            'fb99403b4f6707454eef3f8552cded3e48e230dd4a118c7ada6e78e1a52fa3a4'
            '6b24642ba9fb78256eb2e25185ad33db1e175abeff766bf425a3d505d9d7257b'
            '792c95739e89a6db241934230ecf6692dab8811da37439256321924793a2b732')

prepare() {
  cd $pkgname-$pkgver

  # Handle GIF with ImageMagick
  patch -Np1 -i ../0001-Handle-GIF-with-ImageMagick.patch

  # Create output directory if not exist
  patch -Np1 -i ../0001-Create-output-directory-if-not-exist.patch

  # Use standard icon names
  patch -Np1 -i ../0001-Use-standard-icon-names.patch

  # Add support for more formats
  patch -Np1 -i ../0001-Add-support-for-conversion-and-selection-of-OPUS-aud.patch
  patch -Np1 -i ../0001-Add-support-for-conversion-and-selection-of-WEBP-ima.patch
}

build() {
  arch-meson $pkgname-$pkgver build
  meson compile -C build
}

package() {
  meson install -C build --destdir "$pkgdir"
  ln -s com.github.robertsanseries.ciano "$pkgdir/usr/bin/$pkgname"
}
